package com.ruoyi.auth.utils;

import java.util.Random;
import java.util.stream.IntStream;

/**
  * @author luce
  * @date 2021年08月06日 14:18
  */
public class RandomCode {

   /**
     * 随机短信验证码
     * @param length int
     * @return String
     */
   public static String createSmsCode(int length) {
       Random random = new Random();
       StringBuilder builder = new StringBuilder();
       IntStream.range(0, length).forEach(i -> builder.append(random.nextInt(10)));
       return builder.toString();
   }
}
